﻿using MyFirstWPF.ViewModel;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace MyFirstWPF.View
{
    /// <summary>
    /// Page2.xaml 的交互逻辑
    /// </summary>
    public partial class Page2 : Page
    {
        public static string dbPath = "../../studyPlan.db";
        public Page2()
        {
            InitializeComponent();
            reInitCards();
        }

        private void reInitCards()
        {
            wp2.Children.Clear();
            using (var db = new StudyPlanDb(dbPath))
            {
                List<TaskInfo> taskList = db.MyQuery<TaskInfo>(x => x.GetEndTime() <= DateTime.Now && x.userId == LoginView.myId);
                taskList.Reverse();
                for (int i = 0; i < taskList.Count; i++)
                {
                    wp2.Children.Add(new UserControl2(taskList[i]));
                }
            }
        }
    }
}
